package role
{
	public class RoleCharacterCreatePlayerBase extends RoleCharacterPlayerBase
	{
		private var _roleCharacterStateSet:RoleCharacterStateSet=new RoleCharacterStateSet();
		private var _roleXml:XML;
		private var _xmlStates:XMLList;
		private var _callBack:Function;
		
		public function RoleCharacterCreatePlayerBase(roleXml:XML, callBack:Function)
		{
			super(callBack);
			_roleXml=roleXml;
			_callBack=callBack;
			
			CreateRole();
		}
		
		private function CreateRole():void
		{
			_roleCharacterStateSet=new RoleCharacterStateSet();
			_xmlStates=_roleXml.states.state;//取得状态集
			for each(var state:XML in _xmlStates)
			{
				var roleCharacterCreateStateBase:RoleCharacterCreateStateBase=new RoleCharacterCreateStateBase(state);
				roleCharacterCreateStateBase.addEventListener(RoleCharacterEvent.CHARACTER_STATEBASE_ALL_LOAD_COMPLETE, stateBaseComplete);
			}
		}
		
		private function stateBaseComplete(evt:RoleCharacterEvent):void
		{
			_roleCharacterStateSet.push(evt.data as RoleCharacterStateItem);
			
			if(_roleCharacterStateSet.length>=_xmlStates.length())
			{
				super.sceneCharacterStateSet=_roleCharacterStateSet;
			}
		}
	}
}